package com.changgou.goods.feign;

import com.changgou.goods.pojo.Sku;
import com.changgou.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author tang.qingbo
 * @Date 2020/8/28 13:32
 * @Version 1.0
 */
@RequestMapping("/sku")
@FeignClient(name = "goods")//远程调用的服务名
public interface SkuFeign {

    /**
     * 回滚库存
     *
     * @param skuId
     * @param num
     * @return
     */
    @GetMapping("/skuNumRollback")
    Result skuNumRollback(@RequestParam("skuId") String skuId,@RequestParam("num") Integer num);

    /**
     * 下单减少库存
     */
    @GetMapping("/decr/count")
    Result reduceCount(@RequestParam Map<String, Integer> dataMap);

    /**
     * 根据审核状态查询sku列表
     */
    @GetMapping("/status/{status}")
    Result<List<Sku>> findByStatus(@PathVariable("status") String status);

    /**
     * sku多条件搜索,远程调用时传入spuId,进行查询sku信息
     * @param sku
     * @return
     */
    @PostMapping(value = "/search")
    Result<List<Sku>> findList(@RequestBody(required = false) Sku sku);

    /***
     * 根据ID查询Sku数据
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    Result<Sku> findById(@PathVariable("id") String id);
}
